]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
runDialog: Ignore expected IO errors while enumerating $PATH
authorRui Matos <tiagomatos@gmail.com>
Mon, 18 Mar 2013 14:53:11 +0000 (15:53 +0100)
committerRui Matos <tiagomatos@gmail.com>
Mon, 18 Mar 2013 17:00:12 +0000 (18:00 +0100)
$PATH might contain non-existent or non-directory entries. Ignore
those error cases.

https://bugzilla.gnome.org/show_bug.cgi?id=696064

js/ui/runDialog.js

index bedea40f85fa61ba05b231d8d985b437ca6c5ff2..9d288d92a8732d45e312f81ecd3514d6744d6ec5 100644 (file)
@@ -161,16 +161,22 @@ const RunDialog = new Lang.Class({
         let paths = GLib.getenv('PATH').split(':');
         paths.push(GLib.get_home_dir());
         let someResults = paths.map(function(path) {
-            let file = Gio.File.new_for_path(path);
-            let fileEnum = file.enumerate_children('standard::name', Gio.FileQueryInfoFlags.NONE, null);
-            let info;
             let results = [];
-            while ((info = fileEnum.next_file(null))) {
-                let name = info.get_name();
-                if (name.slice(0, text.length) == text)
-                    results.push(name);
+            try {
+                let file = Gio.File.new_for_path(path);
+                let fileEnum = file.enumerate_children('standard::name', Gio.FileQueryInfoFlags.NONE, null);
+                let info;
+                while ((info = fileEnum.next_file(null))) {
+                    let name = info.get_name();
+                    if (name.slice(0, text.length) == text)
+                        results.push(name);
+                }
+            } catch (e if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.NOT_FOUND) &&
+                           !e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.NOT_DIRECTORY))) {
+                log(e);
+            } finally {
+                return results;
             }
-            return results;
         });
         let results = someResults.reduce(function(a, b) {
             return a.concat(b);